<?php
/** 
 * Called using AJAX to check whether this is the user's 1st login
 */
define('NOROBOT', TRUE);
define('CURSCRIPT', 'GFCcheck');
require_once './include/common.inc.php';
require_once './plugins/gfc/common.php';
require_once './plugins/gfc/discuz.func.php';
if ($_REQUEST['action'] == "checkgfcid") {
  $profile = getGFCProfile();
  if (!$profile) {
    debuglog(__FILE__.": can not get GFC Profile");
    echo "ERROR";
  } else {
    $gfcid = $profile['id'];
    if (IsGFCidRegistered($gfcid)) {
      //login
      $ret = "1";
    } else {
      //register
      $ret = "0";
    }
    echo $ret;
  }
} else if ($_REQUEST['action'] == "checkusername") {
  $username = $_REQUEST["username"];
  if (IsUsernameAvailable($username)) {
    echo "1";
  } else {
    echo "0";
  }
} else if ($_REQUEST['action'] == "checkprofile") {
  $profile = getGFCProfile();
  if (CheckProfile($profile) > 0) {
    echo "1";
  } else {
    echo "0";
  }
}
?>